//
//  MVPController.m
//  PrintJob
//
//  Created by blank on 2017/5/8.
//  Copyright (c) 2017 CYN. All rights reserved.
//

#import "MVPController.h"
#import "Presenter.h"
#import "MVPModel.h"
#import "MVPView.h"
#import "ServiceFactory.h"
#import "PrintService.h"


@interface MVPController ()

@property(nonatomic, retain) Presenter  *presenter;

@property(nonatomic, retain) MVPView    *mvpView;

@property(nonatomic, retain) MVPModel   *mvpModel;

@end

@implementation MVPController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    [self.presenter.mvpView printOnView:self.presenter.mvpModel.content];
    [self.view setBackgroundColor:[UIColor grayColor]];
    [self.view addSubview:self.presenter.mvpView];
    [self.presenter printTask];
}


- (Presenter *)presenter {
    if (!_presenter) {
        _presenter = [[Presenter alloc] init];
    }
    return _presenter;
}

- (MVPView *)mvpView {
    if (!_mvpView) {
        _mvpView = [[MVPView alloc] init];
        [_mvpView setFrame:self.view.bounds];
        [_mvpView setBackgroundColor:[UIColor grayColor]];
        [self.view addSubview:_mvpView];
    }
    return _mvpView;
}

- (MVPModel *)mvpModel {
    if (!_mvpModel) {
#if 0
        _mvpModel = [[MVPModel alloc] init];
        [_mvpModel setContent:@"line0"];
#else
        _mvpModel = [[ServiceFactory instance].printService printModel];

#endif
    }
    return _mvpModel;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
